<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/10 0010
 * Time: 11:02
 */

namespace Cuke\Models;

use Phalcon\Mvc\Model\MetaData;

/**
 * 管理员
 * @package Cuke\Models
 */
class CukeAdmin extends ModelBase
{
    /**
     * @Primary
     * @Identity
     * @Column(type="integer", nullable=false)
     */
    public $user_id;
    public $account;
    public $password;
    public $realname;
    public $email;
    public $phone;
    public $avatar;
    public $status;
    public $role;
    public $create_at;
    public $create_id;
    public $update_at;
    public $update_id;
    public $last_login_time;

    /**
     *  初始方法
     */
    public function initialize()
    {
        parent::initialize();

    }

    public function getSource()
    {
        return 'cuke_admin';
    }


    public function beforeCreate()
    {
        $url = $this->getDI()->getShared('url');

        $this->create_at = date('Y-m-d H:i:s');
        if(empty($this->avatar)){
            $this->avatar =  $url->get('static/images/avatar.png');
        }
    }

    public function beforeUpdate()
    {
        $this->update_at = date('Y-m-d H:i:s');
    }
}